<template>
  <div class="order-confirm">
    <nav-bar title="确认订单"
             bgColor="#eeeeee"
             textColor="#666666"></nav-bar>
    <div class="confirm-content">
      <li class="confirm-pattern">收货方式：
        <span :class="{'active-pattern': pattern == 1}"
              @click="pattern=1">邮寄</span>
        <span :class="{'active-pattern': pattern == 2}"
              @click="pattern=2">自提</span>
      </li>
      <address-card-item @click.native="$router.push({path: '/addressList'})"></address-card-item>
      <div class="good-info">
        <order-good-card></order-good-card>
        <div class="good-num">
          <span>购买数量</span>
          <van-stepper v-model="value"
                       integer
                       button-size="22"></van-stepper>
        </div>
        <div class="good-num">
          <span>配送方式</span>
          <span>快递包邮</span>
        </div>
        <div class="good-num">
          <span>金额</span>
          <span class="point-count">22</span>
        </div>
      </div>
      <!-- 备注 -->
      <van-field class="good-remarks"
                 v-model="remarks"
                 label="备注"
                 placeholder="选填，请先和商家协商一致"></van-field>
    </div>
    <div class="confirm-footer">
      <li>实付金额：<span>¥199.00</span></li>
      <van-button :loading="submitLoading"
                  round
                  @click="submitOrder">提交订单</van-button>
    </div>
    <pay-popup v-model="payShow"
               @paySuccess="paySuccess"></pay-popup>
  </div>
</template>

<script>
import NavBar from '@/components/NavBarSecond'
import AddressCardItem from '@/components/AddressCardItem'
import OrderGoodCard from '@/components/OrderGoodCard'
import PayPopup from '@/components/PayPopup'
export default {
  data () {
    return {
      pattern: 1, // 邮寄方式 1邮寄2自提
      remarks: '',
      value: 1,
      submitLoading: false,
      payShow: false,
    };
  },
  components: {
    NavBar,
    AddressCardItem,
    OrderGoodCard,
    PayPopup
  },
  created () { },
  methods: {
    submitOrder () {
      this.submitLoading = true;
      setTimeout(() => {
        this.payShow = true;
        this.submitLoading = false;

      }, 1000);
    },
    paySuccess () {
      // this.payShow = false;
      this.$router.push({ path: '/orderSuccess' })
    }
  }
}

</script>

<style lang='scss'>
.order-confirm {
  @include top-page;
  .confirm-content {
    flex: 1;
    background-color: #f1f1f1;
    box-sizing: border-box;
    padding: 0 0.1rem;
    .confirm-pattern {
      height: 1rem;
      @include flex-center;
      span {
        height: 0.4rem;
        width: 1.4rem;
        border: 1px solid #999999;
        border-radius: 1rem;
        font-size: 0.26rem;
        color: #999999;
        margin: 0 0.3rem;
        @include flex-center;
      }
      .active-pattern {
        color: #ffffff;
        background-color: #fd5112;
        border: none;
      }
    }
  }
  .confirm-footer {
    height: 1rem;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    padding: 0 0.3rem 0 0.6rem;
    li {
      @include flex-center;
      font-size: 0.26rem;
      span {
        font-weight: 600;
        color: #e93721;
      }
    }
    .van-button {
      height: 0.6rem;
      width: 2.5rem;
      background: linear-gradient(to right, #e93522, #e7560a);
      font-size: 0.3rem;
      color: #fcf8f8;
    }
  }
  .good-info {
    box-sizing: border-box;
    width: 100%;
    padding: 0.25rem;
    background-color: #fff;
    border-radius: 0.15rem;
    margin-top: 0.1rem;

    .good-num {
      width: 100%;
      height: 0.8rem;
      box-sizing: border-box;
      padding: 0 0.2rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 0.26rem;
      color: #131415;
      .point-count {
        color: #f15050;
      }
    }
  }
  .good-remarks {
    width: 100%;
    margin-top: 0.1rem;
    border-radius: 0.15rem;
    box-sizing: border-box;
    padding-left: 0.4rem;
    .van-field__label {
      width: 0.8rem;
    }
  }
}
</style>